from django.db import models
#
# # Create your models here.
#
# #要创建一个用户详情表从而使前端页面展示出数据
# #此处不应该继承model.Model 应该继承之前写好的集群ModelSetMixin
from django.contrib.auth.models import User
#
from utils.modelsMixin import ModelSetMixin

class UserDetail(ModelSetMixin):
    SEX_CHOICES = (
        (0,'男'),
        (1,'女'),
    )
    avatar = models.TextField(null=True,blank=True,verbose_name='头像')
    phone = models.CharField(null=True,blank=True,verbose_name='手机号',max_length=11,unique=True)#unique=True是只能唯一
    age = models.IntegerField(null=True,blank=True,verbose_name='年龄')
    sex = models.IntegerField(null=True,blank=True,verbose_name='性别',choices=SEX_CHOICES)
    birthday = models.DateTimeField(null=True,blank=True,verbose_name='生日')
    synopsis = models.TextField(null=True,blank=True,verbose_name='简介')

    user = models.OneToOneField(User,on_delete=models.DO_NOTHING,verbose_name='用户')
    class Meta:
        db_table = 'user_detail'
        verbose_name = '用户详情'
        verbose_name_plural = verbose_name




